<%= stylesheet_link_tag 'sprint_backlog' %>

<div id="sprintBacklogMenu" class="subMenu">
	Projekt w&auml;hlen <%= select("project_to_user", "project_id", ProjectToUser.find_all_by_user_id(current_user.id).collect{|u| [Project.find_by_id(u.project_id).name, u.project_id]}, :selected => current_user.current_project_id) %>
	<span class="subMenuPipe"></span>
	Sprint w&auml;hlen <%= select("sprint_backlog", "sprint_backlog_id", SprintBacklog.find_all_by_project_pid(current_user.current_project_id).collect{|u| [u.sprint_start.to_formatted_s(:short)+" - "+u.sprint_end.to_formatted_s(:short), u.id]}, :selected => @show_sb_id) %>
	<span class="subMenuPipe"></span>
	<a href="javascript:void(null)" id="showHideProjectChart"><%= image_tag("layout/Info.png", :id => "projectChartIcon", :alt => "Das Projekt Chart einblenden", :class => "icon") %></a>
	<a href="javascript:void(null)" id="showHideSprintInformation"><%= image_tag("layout/About.png", :id => "sprintInformationIcon", :alt => "Sprint Informationen ausblenden", :class => "icon") %></a>
	<span class="subMenuPipe"></span>
</div>

<% @hide=true  %>
<%= render :partial => "product_backlogs/linechart" %>
<div id="wrapChart"><!--#--></div>
<%= render :partial => "linechart" %>
<div id="wrapSprintInformation">
	<div id="sprintInformation">
		<table>
			<tr>
				<td class="headline">Sprint Nummer</td>
				<td><%= @spnr %></td>
				<td class="headline">Enthaltene User Stories</td>
				<td>
                                <%=
                                  @count = 0
                                  @column.each do |status, user_story|
                                    @count += user_story.count
                                  end
                                  @count
                                  #@todo.count+@finished.count+@ongoing.count
                                %>
                                </td>
			</tr>
			<tr>
				<td class="headline">
					Gesamtpunktzahl
				</td>	
				<td><%= @sumOfRating %></td>
				<td class="headline">
					Punktzahl abgeschlossen
				</td>
				<td><%= @sumOfFinished
%></td>
			</tr>
			<tr>
				<td class="headline">Sprint gestartet</td>
				<td><%= @sprint.sprint_start.to_formatted_s(:short) %></td>
				<td class="headline">Sprint endet</td>
				<td><%= @sprint.sprint_end.to_formatted_s(:short) %></td>
			</tr>
		</table>		 
	</div>
	<div id="sprintChart"><!-- # ---></div>
</div>

<div id="sprintbacklog">
    <% @column.each do |status,user_stories| %>
	<div class="wrapSprintbacklogColumn" style="width: <%= (100/@column.count()).round() %>%">
		<div class="sprintbacklogColumn">
                        <% s = status.dup %>
			<div class="sprintbacklogHeadline" id="sprintbacklogHeadline_<%= status %>">
			<h2><%= s.gsub(/--leer--/, " ") %> (<%= user_stories.count %>)</h2>
			</div>
			<div class="wrapStories" id="sprintbacklogState_<%= status %>">
				<% user_stories.each do |story|   %>
				<div class="sprintbacklogStory" id="sprintbacklogStory_<%= story.id %>">
					<div class="actions">					
						<a href="javascript:void(null)" class="resetUserStory" id="resetUserStoryRating_<%= story.id %>"><%= image_tag("layout/Redo.png", :id => "redoIcon", :alt => "Die User Story neu bewerten lassen", :class => "icon") %></a>
					</div>
					<div class="rating">
						<%= 
							if story.user_story_rating_id == nil 
								"?"
							else 
								UserStoryRating.find_by_id(story.user_story_rating_id).rating
							end 
						%>
					</div>
					<span class="hint userStoryId">#<%= story.id %></span>
					<h3><%= story.headline %></h3>
					
					<p>
						<%= story.description %>
					</p>
					
					<p>
						<span class="hint">Zuletzt aktualisiert am <%= story.updated_at.to_formatted_s(:short) %>. Erstellt am <%= story.created_at.to_formatted_s(:short) %> durch <%= User.find_by_id(story.user_pid).name %>. Status: <%= UserStoryState.find_by_id(story.user_story_state_pid).status %> Priorität: <%= UserStoryPriority.find_by_id(story.user_story_priority_pid).priority %></span>
					</p>
				</div>
				<% end %>
			</div>
		</div>
	</div>
  <% end %>
  <!-- Important! -->
  <div style="clear: both; overlow: hidden;"><!-- # --></div>
</div>
